home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1993 November
/
JCSM Shareware Collection - 1993-11.iso
/
cl720
/
sst115j.lzh
/
EDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-01
|
2KB
|
76 lines
/* ------------------------------------------------------------------------ */
/* tdemo.c */
/* ------------------------------------------------------------------------ */
#include <dos.h>
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <stdlib.h>
#include <conio.h>
#include "sstkey.h"
#include "sstwin.h"
#include "sstedt.h"
void ShowEditor (void);
void main (void);
/* ------------------------------------------------------------------------ */
/* demo on editor */
/* ------------------------------------------------------------------------ */
void ShowEditor(void)
#define LWID (int)80
#define WHT (int)20
#define PADHT 20
{
char buf [PADHT] [LWID];
char notefile [] = "test.txt";
WINDOW *wnd;
FILE *fp, *fopen();
int i, ctr = 0;
setmem(buf, sizeof buf, 0x00);
if ((fp = fopen(notefile, "rt")) != NULL) {
while (fread(buf [ctr], LWID, 1, fp))
ctr++;
fclose(fp);
}
wnd = Westablish
((80-(LWID+2))/2, (25-(WHT+2))/2, WHT+2, LWID+2);
Wsetborder(wnd, BRD_SINGLE);
Wsettitle(wnd, " VB (very basic) Eopen ",JUST_C);
Wsetcolour(wnd, WIN_FACE, CYAN, BLUE, DIM);
Wsetcolour(wnd, WIN_TITLE, CYAN, YELLOW, DIM);
Wsetcolour(wnd, WIN_ACCENT, LIGHTGRAY, CYAN, DIM);
Wsetcolour(wnd, WIN_BORDER, CYAN, BLACK, DIM);
Wshow(wnd);
Eopen(wnd, (char*) buf, LWID * PADHT);
Wdelete(wnd);
ctr = PADHT;
while (--ctr) {
for (i = 0; i < LWID; i++)
if (buf [ctr] [i] != ' ')
break;
if (i < LWID)
break;
}
fp = fopen(notefile, "w");
for (i = 0; i < ctr+1; i++)
fwrite(buf[i], LWID, 1, fp);
fclose(fp);
}
/* ------------------------------------------------------------------------ */
void main(void)
{
ShowEditor();
}